From: Ian Jackson Date: Fri, 11 May 2012 17:59:05 +0000 (+0100) Subject: libxl: remove malloc failure handling from NEW_EVENT X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~8480 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:/?a=commitdiff_plain;h=172af31d56bad27a570c3f4e2bd1e82083afa0b0;p=xen.git libxl: remove malloc failure handling from NEW_EVENT Change to use libxl__zalloc, where allocation failure is fatal. Also remove a spurious semicolon from the helper macro. Signed-off-by: Ian Jackson Acked-by: Ian Campbell Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 482adaa6d7..4d01cf86b9 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -789,7 +789,6 @@ static void domain_death_occurred(libxl__egc *egc, *evg_upd = evg_next; libxl_event *ev = NEW_EVENT(egc, DOMAIN_DEATH, evg->domid); - if (!ev) return; libxl__event_occurred(egc, ev); @@ -876,7 +875,6 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, if (!evg->shutdown_reported && (got->flags & XEN_DOMINF_shutdown)) { libxl_event *ev = NEW_EVENT(egc, DOMAIN_SHUTDOWN, got->domain); - if (!ev) goto out; LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " shutdown reporting"); diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 460ef66b6f..63719b2b5d 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -989,13 +989,7 @@ libxl_event *libxl__event_new(libxl__egc *egc, { libxl_event *ev; - ev = malloc(sizeof(*ev)); - if (!ev) { - LIBXL__EVENT_DISASTER(egc, "allocate new event", errno, type); - return NULL; - } - - memset(ev, 0, sizeof(*ev)); + ev = libxl__zalloc(0,sizeof(*ev)); ev->type = type; ev->domid = domid; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d5cf69a715..a407317d3b 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -654,10 +654,10 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type, uint32_t domid); /* Convenience function. * Allocates a new libxl_event, fills in domid and type. - * If allocation fails, calls _disaster, and returns NULL. */ + * Cannot fail. */ #define NEW_EVENT(egc, type, domid) \ - libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid)); + libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid)) /* Convenience macro. */ /*